<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button>点我</button>
    <input type="text" />
    <script>
      //dom对象
      const btn = document.querySelector("button");
      btn.addEventListener("mousemove", () => {
        console.log("鼠标点击了  ----->  ", "鼠标进入了区域");
      });
      btn.addEventListener("mouseleave", () => {
        console.log("鼠标离开了区域  ----->  ", "鼠标离开了区域");
      });
      //1、通过document.querySelector拿到一个dom节点
      const ipt = document.querySelector("input");
      //2、监听聚焦事件
      ipt.addEventListener("focus", () => {
        console.log("用户激活了输入框  ----->  ", "聚焦");
      });
      // 主动控制输入框聚焦，让一个输入框获得焦点
      ipt.focus();
      //3、监听失焦事件
      ipt.addEventListener("blur", () => {
        console.log("用户输入完了内容 ----->  ", "失去焦点");
      });
    </script>
  </body>
</html>
